#ifndef __PAGE_MANAGER_H__
#define __PAGE_MANAGER_H__

#include <stdint.h>
#include <stdlib.h>

typedef enum {
	PAGE_CONDITION_ENTER,
	PAGE_CONDITION_RETURN
}page_condtion_e;

typedef enum {
	PAGE_STATUS_IDLE,
	PAGE_STATUS_INIT,
	PAGE_STATUS_RUN,
	PAGE_STATUS_EXIT
}page_status_e;

typedef void (*SetupCallback_t)(uint8_t); 
typedef void (*ExitCallback_t)(uint8_t);
typedef void (*LoopCallback_t)(void);
typedef void (*EventCallback_t)(uint8_t);

typedef struct
{
    uint8_t * title;
    uint8_t * icon;
    uint8_t status;
    SetupCallback_t SetupCallback; 
    ExitCallback_t ExitCallback;
    LoopCallback_t LoopCallback;
    EventCallback_t EventCallback;
    /* data */
}page_list_t;


typedef enum {
    PAGE_NULL = -1,
    page_id_home,
    page_id_menu,
    page_id_read,
    PAGE_ID_MAX,
}page_id_e;

#define PAGE_REG(name)\
do{\
    extern void page_register_##name(unsigned char pageID);\
    page_register_##name(name);\
}while(0)

extern int current_page;

void page_manager_init(void);
void page_manager_run(void);
void page_register(
    uint8_t page_id,
	uint8_t * _page_title,
	uint8_t * _page_icon,
    SetupCallback_t _SetupCallback,
    LoopCallback_t _LoopCallback,
    ExitCallback_t _ExitCallback,
    EventCallback_t _EventCallback
);
void page_manager_switch_page(uint32_t page_id, uint8_t page_condition);
void page_manager_event_transmit(uint8_t event);
#endif











